import 'package:flutter/material.dart';
import 'package:proj_sfv/component/UserProfile.dart';
import 'package:tencent_cloud_chat_uikit/business_logic/view_models/tui_chat_global_model.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';

class Chat extends StatelessWidget {
  final V2TimConversation selectedConversation;

  const Chat({Key key, this.selectedConversation}) : super(key: key);

  String _getConvID() {
    return selectedConversation.type == 1
        ? selectedConversation.userID
        : selectedConversation.groupID;
  }

  @override
  Widget build(BuildContext context) {
    print('_getConvID ${_getConvID()}');
    return TIMUIKitChat(
      conversation: selectedConversation,
      conversationID: _getConvID() ?? '',
      // groupID or UserID
      conversationType: selectedConversation.type == 1 ?  ConvType.c2c : ConvType.none,
      // Conversation type
      conversationShowName: selectedConversation.showName ?? "",
      // Conversation display name
      onTapAvatar: (_) {
        Navigator.push(
            context,
            MaterialPageRoute(
              builder: (context) =>
                  UserProfile(userID: selectedConversation.userID),
            ));
      }, // Callback for the clicking of the message sender profile photo. This callback can be used with `TIMUIKitProfile`.
    );
  }
}